﻿using System;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using System.Threading.Tasks;

namespace NFinalCoreServer
{
    class Program
    {
        static void Main(string[] args)
        {
            //加载配置文件
            NFinal.Application.Create();
            string url = null;
            if (NFinal.Application.globalConfig.debug.enable)
            {
                url = NFinal.Application.globalConfig.debug.url;
            }
            else
            {
                url = NFinal.Application.globalConfig.server.url;
            }
            var host = new WebHostBuilder()
                .UseKestrel()
                .UseUrls(url)
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseStartup<Startup>()
                .Build();
            Task.Run(() =>
            {
                host.Run();
            });
            if (NFinal.Application.globalConfig.debug.enable)
            {
                Task.Run(() =>
                {
                    System.Diagnostics.Process.Start("explorer.exe", url);
                });
            }
            Console.ReadLine();
        }
    }
}